<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<%@ include file="/web/header.jsp"%>
</head>
<body>
<div class="layui-collapse">
  <div class="layui-colla-item">
    <h2 class="layui-colla-title">绩效信息-条件查询</h2>
    <div class="layui-colla-content layui-show">
	<fieldset class="layui-elem-field layui-field-title" style="margin: 10px">
			<legend>绩效信息-条件查询</legend>
			<div class="layui-field-box">
				<form class="layui-form layui-form-pane" action="">
					<div class="layui-form-item">
						<label class="layui-form-label">员工编号</label>
						<div class="layui-input-inline">
							<input type="text" name="codeEmp" 
								placeholder="请输入员工编号" autocomplete="off" class="layui-input">							 
						</div>						
					
						<label class="layui-form-label">项目编号</label>
						<div class="layui-input-inline">
							<input type="text" name="codePro"
								placeholder="请输入项目编号" autocomplete="off" class="layui-input">
						</div>
						<span>
							<input type="button" value="查询" class="layui-btn layui-btn-sm" lay-submit lay-filter="search">
							<input type="reset" value="重置" class="layui-btn layui-btn-sm layui-btn-primary">
							<input type="button" value="添加" class="layui-btn layui-btn-sm" onclick="openAdd()">
						</span>
						<input type="hidden" name="action" value="page">
						<input type="hidden" name="pageIndex" value="1">
						<input type="hidden" name="pageLimit" value="10">
					</div>
				</form>
			</div>
		</fieldset>
	</div>  
    </div>
  </div>
  <table class="layui-table">
	<colgroup><col width="5%"><col width="15%"><col width="15%"><col width="15%"></colgroup>
	<thead><tr><th>序号</th><th>员工编号</th><th>员工姓名</th><th>项目编号</th><th>项目姓名</th><th>绩效</th><th>操作</th></tr></thead>		
	<tbody></tbody>	
</table>
<div id="pageInfo" style="text-aline:right;padding-right:30px"></div>
<script type="text/javascript">
formSubmit('search','/ScoreServlet','json',function(data){	

	var curr = $("input[name='pageIndex']").val();
	var limit = $("input[name='pageLimit']").val();
	pageInfo('pageInfo',data.count,curr,limit,function(obj,first){ 
		$("input[name='pageIndex']").val(obj.curr);
		$("input[name='pageLimit']").val(obj.limit); 
		if(!first){refresh();}//首次不执行
	});
	     
var html = "";
var tpl = $("#tradd").html();
$.each(data.list,function(i,dom){
	
	var codeEmp = dom.codeEmp?dom.codeEmp:'';
	var nameEmp = dom.nameEmp?dom.nameEmp:'';
	var codePro = dom.codePro?dom.codePro:'';
	var namePro = dom.namePro?dom.namePro:'';
	var score = dom.score?dom.score:'';
	var d = {id:(i+1+(curr-1)*limit),codeEmp:dom.codeEmp,nameEmp:nameEmp,codePro:codePro,namePro:namePro,score:score}
	html += laytpl(tpl).render(d);
	//html +="<tr>"+"<td>"+dom.codeEmp+"</td>"+"<td>"+dom.codePro+"</td>"+"<td>"+dom.score+"</td>"+"</tr>";
})  
$("tbody").html(html);
layer.msg("查询成功",{time:1500});
})
function openAdd(){
		layerOpen("/web/page/score/add.jsp");
	}
function del(codeEmp){
	layerConfirm(function(){
		ajax("/ScoreServlet",{codeEmp:codeEmp,action:'del'},'text',function(data){
			//console.log(data)
			if(data==1){
				 layer.msg("删除成功",refresh); 
			 }else{
				 layer.msg("删除失败");
			 }
		})
	})
}
function openUpd(codeEmp){
	layerOpen("/web/page/score/upd.jsp?codeEmp="+codeEmp,refresh)
}
function refresh(){
	$("input[value='查询']").click();
}
refresh();
</script>
<script type="text/html" id="tradd">
<tr> 
<td>{{d.id}}</td><td>{{d.codeEmp}}</td><td>{{d.nameEmp}}</td><td>{{d.codePro}}</td><td>{{d.namePro}}</td><td>{{d.score}}</td>
 <td> 
	<a href="javascript:del('{{d.codeEmp}}')" class="layui-btn layui-btn-sm layui-btn-danger"> 
 		<i class='layui-icon layui-icon-delete'></i> 
 	</a> 
 	<input type="button" class="layui-btn layui-btn-xs" value="修改" onclick="openUpd('{{d.codeEmp}}')">
 </td>
</tr>
</script>
</body>
</html>